//
//  PartyTestResultController.m
//  UESTCPioneer
//
//  Created by Apple on 14-9-29.
//  Copyright (c) 2014年 Sway. All rights reserved.
//

#import "PartyTestResultController.h"
#import "PartyVirtualTestController.h"
#import "PartyKnowledgeController.h"

@interface PartyTestResultController ()
{
    NSString * _nameText;
    NSString * _resultText;
    NSString * _integral;
}
@end

@implementation PartyTestResultController

-(id)initWithName:(NSString *)name result:(NSString *)result  integral:(NSString *)integral{
    if (self) {
        _nameText = name;
        _resultText = result;
        _integral = integral;
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:232.0f/255.0f green:233.0f/255.0f  blue:232.0f/255.0f  alpha:1];
    //添加UI
    [self addUI];
}

-(void)addUI{
    
    //1.添加背景图片
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 320)];
    [imageView setImage:[UIImage imageNamed:@"reward.png"]];
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:imageView];
    
    //2.添加姓名
    UILabel * nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 130, 100, 15)];
    nameLabel.font = [UIFont systemFontOfSize:14.0f];
    [imageView addSubview:nameLabel];
    nameLabel.text = _nameText;
    
    //3.添加分数
    CGFloat y = CGRectGetMaxY(nameLabel.frame);
    CGFloat width = self.view.frame.size.width;
    //    CGFloat height = imageView.frame.size.height - y - 10;
    UILabel * resultText = [[UILabel alloc] initWithFrame:CGRectMake(40, y , width - 65, 60)];
    resultText.text = _resultText;
    resultText.numberOfLines = 0;
    resultText.font = [UIFont systemFontOfSize:14.0f];
    [imageView addSubview:resultText];
    
    //4.添加按钮
    CGFloat btnY = CGRectGetMaxY(imageView.frame);
    UIButton * againBtn = [[UIButton alloc] initWithFrame:CGRectMake(20, btnY, 100, 30)];
    againBtn.tag = 1;
    [againBtn setTitle:@"再来一次" forState:UIControlStateNormal];
    [againBtn setTitle:@"再来一次" forState:UIControlStateHighlighted];
    [againBtn setBackgroundImage:[UIImage imageNamed:@"background.png"] forState:UIControlStateNormal];
    [againBtn addTarget:self action:@selector(choseButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    CGFloat endX = self.view.frame.size.width - 120;
    UIButton * endBtn = [[UIButton alloc] initWithFrame:CGRectMake(endX, btnY, 100, 30)];
    endBtn.tag = 2;
    [endBtn setTitle:@"结束答题" forState:UIControlStateNormal];
    [endBtn setTitle:@"结束答题" forState:UIControlStateHighlighted];
    [endBtn setBackgroundImage:[UIImage imageNamed:@"background.png"] forState:UIControlStateNormal];
    [endBtn addTarget:self action:@selector(choseButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    
    [self.view addSubview:againBtn];
    [self.view addSubview:endBtn];
    
}

#pragma mark  - 响应函数
-(void)choseButtonClick:(UIButton *)btn{
    if (btn.tag == 1) {
        [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
    } else if (btn.tag == 2) {
        [self.navigationController popToRootViewControllerAnimated:YES];
        
    }
}
@end
